package com.geeklei.media.ui.common;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class PlayerSettings{
    public static final int AUDIO_EFFECT_OFF = 1;
    public static final int AUDIO_EFFECT_ON = 0;
    public static final int FORCE_FULL_SCREEN_OFF = 1;
    public static final int FORCE_FULL_SCREEN_ON = 0;
    public static final String PREF_KEY_AUDIO_EFFECT = "key_audio_effect";
    public static final String PREF_KEY_FORCE_FULL_SCREEN = "key_force_full_screen";

    public boolean isAudioEffectOn() {
        return getIntValue(PREF_KEY_AUDIO_EFFECT, 0) == 0;
    }

    public void setAudioEffect(boolean z) {
        saveIntValue(PREF_KEY_AUDIO_EFFECT, z ? 0 : 1);
    }

    public boolean isForceFullScreen() {
        return getIntValue(PREF_KEY_FORCE_FULL_SCREEN, 1) == 0;
    }

    public void setForeceFullScreen(boolean z) {
        saveIntValue(PREF_KEY_FORCE_FULL_SCREEN, z ? 0 : 1);
    }

    protected Context mContext;

    public void init(Context context) {
        this.mContext = context;
    }

    SharedPreferences getSharedPreference() {
        return this.mContext.getSharedPreferences("video_player", 0);
    }

    private void saveIntValue(String str, int i) {
        try {
            Editor edit = getSharedPreference().edit();
            edit.putInt(str, i);
            edit.apply();
        } catch (Exception e) {
        }
    }

    private int getIntValue(String str, int i) {
        try {
            i = getSharedPreference().getInt(str, i);
        } catch (Exception e) {
        }
        return i;
    }
}
